import { request } from './request'

// 添加地址
export function address(data) {
  return request({
    url: '/api/address',
    method: 'post',
    data
  })
}

// 地址列表
export function addressList() {
  return request({
    url: '/api/address'
  })
}

// 地址详情
export function addressDetail(addressId) {
  return request({
    url: `/api/address/${addressId}`
  })
}

// 更新地址
export function addressEdit(addressId, data) {
  return request({
    url: `/api/address/${addressId}`,
    method: 'put',
    data
  })
}

// 删除地址
export function addressDelete(addressId) {
  return request({
    url: `/api/address/${addressId}`,
    method: 'delete'
  })
}

// 设置为默认地址
export function addressDefault(addressId) {
  return request({
    url: `/api/address/${addressId}/default`,
    method: 'patch'
  })
}
